package com.liu.mongodb.demo.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;

@Data
@Document(collection = "student")  //指定要对应的文档名(表名）
public class Student implements Serializable {

    @Id
    @Field("_id")
    private Long id; //将默认的string型id转为long型，替换系统的_id字段

    @Field("student_id")
    private Long studentId;//保存到数据库的指定字段，可以让程序字段和数据库字段不一致
    private String name;
    private int age;
    private String address;
}
